package demo.virtuemart.productdisplay;

import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import demo.virtuemart.Util.TestUtil;
import demo.virtuemart.cart.TestSuiteBase;

public class TestCase_C2 extends TestSuiteBase{
	
	String [] runmode=null;
	static int count = -1;
	static boolean pass=false;
	static boolean fail=false;
	static boolean skip=false;
	
	@BeforeTest
	public void checkTestSkip() throws Throwable 
	{
		if(!TestUtil.isTestCaseRunnable(suite_productdisplay_xls, this.getClass().getSimpleName()))
		{
			logs.debug("Log Message---- Skipping the test case" +this.getClass().getSimpleName()+"as the run mode set to no");
			skip=true;
			throw new SkipException("Skipping the test case" +this.getClass().getSimpleName()+"as the run mode set to no");
		}
	}
	
	@Test(dataProvider = "getTestData")
	public void testCaseC2(String dataC2_1,
			   String dataC2_2,
			   String dataC2_3,
			   String dataC2_4,
			   String runmodes
			  )
	{
		count = count+1;
		if(!runmode[count].equalsIgnoreCase("Y"))
		{	
		throw new SkipException("Run mode for test set data set " +count + "is set to no");
		}
		logs.debug("Executing C2");
		logs.debug(dataC2_1+ "----"+dataC2_2 +"-------" +dataC2_3+"-------" +dataC2_4+"-------"+runmodes);
	}
	
	@DataProvider
	public Object[][] getTestData() throws Throwable
	{
		return TestUtil.getData(suite_productdisplay_xls, this.getClass().getSimpleName());
	}
	@AfterMethod
	public void report() throws Throwable
	{
		if(skip)
		{
			TestUtil.reportDataSetResult(suite_cart_xls, this.getClass().getSimpleName(), count+2, "Skip");
		}
		else if(fail)
		{
			  TestUtil.reportDataSetResult(suite_cart_xls, this.getClass().getSimpleName(), count+2, "Fail");
		}
		else
		{
			  TestUtil.reportDataSetResult(suite_cart_xls, this.getClass().getSimpleName(), count+2, "Pass");
		}
		skip=false;
		fail=false;
		pass=false;
	}

}
